<?php
/**
 * Created by PhpStorm.
 * User: leo
 * Date: 2018/5/16
 * Time: 13:07
 */
header('Content-Type:application/json');
include '../classes/logincheck.php';
include '../classes/conn.php';
if(islogin()!='stu_login'){
    die('error');
}
$class=$_POST['class'];
$num=$_SESSION['stu_num'];
$homework=array();

$query1="select num from student where class='{$class}'";
$res=mysql_query($query1);
if(!mysql_num_rows($res)){
    die('error');
}

$query="select * from homework where class='{$class}'";
$res=mysql_query($query);
if(!mysql_num_rows($res)){
    die('none');
}
while ($row=mysql_fetch_assoc($res)){
    $homework[]=$row;
}
$data=json_encode($homework);
echo $data;
mysql_close($conn);